/**
 * 
 */
package com.axt.dbaudit.action.cfg;

import java.util.List;
import org.apache.struts2.json.annotations.JSON;

import com.axt.dbaudit.bean.cfg.SafeCfgBean;
import com.axt.dbaudit.model.cfg.SafeCfg;
import com.axt.soa.action.BaseAction;
import com.axt.soa.msg.types.MsgParam;

public class SafeCfgAction extends BaseAction{
	private SafeCfgBean safeCfgBean = new SafeCfgBean();
	private List<SafeCfg> safeCfgs = null;
	
	@JSON(name="safecfgs")
	public List<SafeCfg> getSafeCfgs() {
		return safeCfgs;
	}
	public void setSafeCfgs(List<SafeCfg> safeCfgs) {
		this.safeCfgs = safeCfgs;
	}
	
	@JSON(name="errcode")
	public int getErrcode() {
		return errcode;
	}
	
	@JSON(name="errinfo")
	public String getErrinfo() {
		return errinfo;
	}
	
	private int au_tryTimes ;
	private int au_dealway ;
	private int au_locklength ;
	private int au_timeoutCfg ;
	/**
	 * @return the au_tryTimes
	 */
	public int getAu_tryTimes() {
		return au_tryTimes;
	}
	/**
	 * @param au_tryTimes the au_tryTimes to set
	 */
	public void setAu_tryTimes(int au_tryTimes) {
		this.au_tryTimes = au_tryTimes;
	}
	/**
	 * @return the au_dealway
	 */
	public int getAu_dealway() {
		return au_dealway;
	}
	/**
	 * @param au_dealway the au_dealway to set
	 */
	public void setAu_dealway(int au_dealway) {
		this.au_dealway = au_dealway;
	}
	/**
	 * @return the au_locklength
	 */
	public int getAu_locklength() {
		return au_locklength;
	}
	/**
	 * @param au_locklength the au_locklength to set
	 */
	public void setAu_locklength(int au_locklength) {
		this.au_locklength = au_locklength;
	}
	/**
	 * @return the au_timeoutCfg
	 */
	public int getAu_timeoutCfg() {
		return au_timeoutCfg;
	}
	/**
	 * @param au_timeoutCfg the au_timeoutCfg to set
	 */
	public void setAu_timeoutCfg(int au_timeoutCfg) {
		this.au_timeoutCfg = au_timeoutCfg;
	}
	/**
	 * 获取安全配置
	 */
	public String querySafeCfg()
	{
		setSafeCfgs(safeCfgBean.querySafeCfg(serverPath));
		setErrcode(safeCfgBean.getErrcode());
		setErrinfo(safeCfgBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	/**
	 * 更新安全配置
	 */
	public String updateSafeCfg()
	{
		SafeCfg safeCfg = new SafeCfg();
		safeCfg.setAu_tryTimes(au_tryTimes);
		safeCfg.setAu_dealway(au_dealway);
		safeCfg.setAu_locklength(au_locklength);
		safeCfg.setAu_timeoutCfg(au_timeoutCfg);
		
		safeCfgBean.updateSafeCfg(serverPath, safeCfg);
		setErrcode(safeCfgBean.getErrcode());
		setErrinfo(safeCfgBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
}
